<template>
  <div class="apple-music">
    <div
      class="item"
      @click="todetail(item)"
      v-for="(item, index) in musicList"
      :key="index"
    >
      <div class="left" v-if="item.num" :class="{ active: item.num <= 3 }">
        {{ item.num }}
      </div>
      <div class="item-right">
        <div class="center">
          <div class="top">
            {{ item.name }}
          </div>
          <div class="bottom">
            <i
              class="quality"
              v-if="item.song.privilege.playMaxbr > 990000"
            ></i>

            <span>{{ item.song.artists | filterone }}</span>
            <span v-if="item.song.album.name">-</span>
            <span>{{ item.song.album.name }}</span>
          </div>
        </div>
        <div class="right"></div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  props: {
    musicList: {
      type: Array,
      default: () => {},
    },
  },
  mounted() {},
  filters: {
    filterone(val) {
      var str = "";
      for (var i = 0; i < val.length; i++) {
        str += val[i].name + "/";
      }
      return str.slice(0, str.lastIndexOf("/"));
    },
  },
  methods: {
    todetail(item) {
      this.$emit("musicMessage", item);
    },
  },
};
</script>
<style lang="less" scoped>
.apple-music {
  .item {
    display: flex;
    padding: 0 10px;
    align-items: center;
    .left {
      margin-right: 10px;
    }
    .active {
      color: red;
    }
    .item-right {
      padding: 6px 0;
      border-bottom: 1px solid rgba(0, 0, 0, 0.1);
      flex: 1;
      display: flex;
      overflow: hidden;
      align-items: center;
      justify-content: space-between;
      .center {
        flex: 1;
        padding-right: 10px;
        overflow: hidden;
        .top {
          font-size: 17px;
        }
        .bottom {
          font-size: 12px;
          color: #888;
          .quality {
            background: url("https://s3.music.126.net/mobile-new/img/index_icon_2x.png?5207a28c3767992ca4bb6d4887c74880=")
              no-repeat;
            background-size: 166px 97px;
            display: inline-block;
            width: 12px;
            height: 8px;
            margin-right: 4px;
          }
        }
        div {
          line-height: 1.5;
          text-overflow: ellipsis;
          overflow: hidden;
          white-space: nowrap;
        }
      }
      .right {
        width: 22px;
        height: 22px;
        background: url("https://s3.music.126.net/mobile-new/img/index_icon_2x.png?5207a28c3767992ca4bb6d4887c74880=")
          no-repeat;
        background-position: -24px 0;
        background-size: 166px 97px;
      }
    }
  }
}
</style>